home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / packagetool / sample package / htmlsample sources / ciconbuttons.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  5.8 KB  |  145 lines

  1. /*
  2.     File: CIconButtons.h
  3.     
  4.     Description:
  5.         This file contains type declarations, constants, and routine prototypes
  6.     for accessing the routines implemented in CIconButtons.c.  These routines
  7.     are used to implement the color icon buttons displayed in the top of
  8.     HTMLSample's windows.
  9.     
  10.     HTMLSample is an application illustrating how to use the new
  11.     HTMLRenderingLib services found in Mac OS 9. HTMLRenderingLib
  12.     is Apple's light-weight HTML rendering engine capable of
  13.     displaying HTML files.
  14.  
  15.     Copyright:
  16.         © Copyright 1999 Apple Computer, Inc. All rights reserved.
  17.     
  18.     Disclaimer:
  19.         IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  20.         ("Apple") in consideration of your agreement to the following terms, and your
  21.         use, installation, modification or redistribution of this Apple software
  22.         constitutes acceptance of these terms.  If you do not agree with these terms,
  23.         please do not use, install, modify or redistribute this Apple software.
  24.  
  25.         In consideration of your agreement to abide by the following terms, and subject
  26.         to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  27.         copyrights in this original Apple software (the "Apple Software"), to use,
  28.         reproduce, modify and redistribute the Apple Software, with or without
  29.         modifications, in source and/or binary forms; provided that if you redistribute
  30.         the Apple Software in its entirety and without modifications, you must retain
  31.         this notice and the following text and disclaimers in all such redistributions of
  32.         the Apple Software.  Neither the name, trademarks, service marks or logos of
  33.         Apple Computer, Inc. may be used to endorse or promote products derived from the
  34.         Apple Software without specific prior written permission from Apple.  Except as
  35.         expressly stated in this notice, no other rights or licenses, express or implied,
  36.         are granted by Apple herein, including but not limited to any patent rights that
  37.         may be infringed by your derivative works or by other works in which the Apple
  38.         Software may be incorporated.
  39.  
  40.         The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  41.         WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  42.         WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  43.         PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  44.         COMBINATION WITH YOUR PRODUCTS.
  45.  
  46.         IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  47.         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  48.         GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  49.         ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  50.         OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  51.         (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  52.         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  53.  
  54.     Change History (most recent first):
  55.         Wed, Dec 22, 1999 -- created
  56. */
  57.  
  58.  
  59. #ifndef __CICONBUTTONS__
  60. #define __CICONBUTTONS__
  61.  
  62. #include <Types.h>
  63.  
  64.     /* these are the resource types we use.  ResEdit
  65.     templates for these resource types are defined in
  66.     the application's resource fork. */
  67. enum {
  68.     kIconButtonIDListType = 'RBCL',
  69.     kIconButtonType = 'CICB'
  70. };
  71.  
  72.     /* buttons have three states, and three icons
  73.     for each of those states.  disabled is how it looks
  74.     when it cannot be clicked, up and down define
  75.     how it looks in each of those states. */
  76. enum {
  77.     kCBdisabled = 0,
  78.     kCBup = 1,
  79.     kCBdown = 2
  80. };
  81.  
  82. #pragma options align=mac68k
  83. typedef struct {
  84.     Rect bounds;
  85.     short drawnstate;
  86.     short cicnIDs[3]; /* resource id's for each state's cicn
  87.                 resource.  indexes in this array map to the
  88.                 states defined above. */
  89.     char stringdata[1]; /* variable size c string */
  90. } CIconButton, **CIconButtonHandle;
  91. #pragma options align=reset
  92.  
  93.  
  94. /* NewCIconButton retrieves a new color icon button
  95.     resource from the resource file.  the id number
  96.     corresponds to the resource id of the CICB resource. */
  97. CIconButtonHandle NewCIconButton(short id);
  98.  
  99.  
  100. /* DisposeCIconButton disposes of any structures allocated
  101.     for the color icon button allocated by NewCIconButton. */
  102. void DisposeCIconButton(CIconButtonHandle cicb);
  103.  
  104.  
  105. /* SetCIconButtonPosition sets the color icon button's 
  106.     screen postion. h and v are coordinates in the
  107.     current grafport. */
  108. void SetCIconButtonPosition(CIconButtonHandle cicb, short h, short v);
  109.  
  110.  
  111. /* GetCIconButtonStringData returns a new handled containing
  112.     the string data copied from the color icon resource.  The
  113.     handle will contain a C-style string terminated with a zero
  114.     byte.  It is the caller's responsibility to dispose of this
  115.     handle after it has been used. */
  116. OSErr GetCIconButtonStringData(CIconButtonHandle cicb, Handle *strdata);
  117.  
  118.  
  119. /* DrawCIconButton draws the icon button using the
  120.     as it should appear given the state specified.  state
  121.     should be either kCBdisabled, kCBup, or kCBdown.
  122.     The last state a button is drawn in affects the
  123.     result of TrackCIconButton. */
  124. void DrawCIconButton(CIconButtonHandle cicb, short state);
  125.  
  126.  
  127. /* TrackCIconButton should be called whenever a click is made
  128.     inside of a color icon button.  if the last time the button
  129.     was drawn its state was not kCBup or the click is outside
  130.     of the button, then this routine returns false. */
  131. Boolean TrackCIconButton(CIconButtonHandle cicb, Point where);
  132.  
  133. /* RBCLRsrcHandle defines the resource type used to store
  134.     a list of color icon button resource IDs.  In this example,
  135.     the user configurable button ids are stored in a RBCLRsrcHandle
  136.     resource. */
  137. #pragma options align=mac68k
  138. typedef struct {
  139.     short n;
  140.     short ids[1];
  141. } RBCLResource, **RBCLRsrcHandle;
  142. #pragma options align=reset
  143.  
  144. #endif
  145.